<template>
  <div class="musicPerson w" ref="musicPersonDom">
    <global-title title="音乐人" @titleClick="toSingerPage" />
    <div class="content" v-if="list.length === 0">
      <div class="content_item" v-for="item in 5" :key="item">
        <el-skeleton animated :throttle="500" style="width: 100%">
          <template slot="template">
            <el-skeleton-item
              variant="image"
              style="height: 155px; width: 100%"
            />
            <el-skeleton-item
              variant="p"
              style="height: 30px; width: 100%; margin-top: 8px"
            />
          </template>
        </el-skeleton>
      </div>
    </div>
    <div class="content" v-else>
      <div class="content_item" v-for="item in list" :key="item.id">
        <div class="content_item_pic">
          <GlobalImageDeep
            :url="item.picUrl"
            :imgWidth="155"
            :imgHeight="155"
          />
        </div>
        <div class="name" @click="toSingerDetailsPage(item.id)">
          {{ item.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import ObserverDomToScreen from "../../../../../utils/ObserverDomToScreen.js";
import { getMusicePerson } from "../../../../../api/homeApi";
export default {
  name: "musicPerson",
  components: {},
  data() {
    return {
      list: [],
    };
  },
  created() {
    // this.getMusicePerson();
  },
  mounted() {
    ObserverDomToScreen(this.$refs.musicPersonDom, this.getMusicePerson);
  },
  methods: {
    async getMusicePerson() {
      try {
        const result = await getMusicePerson();
        if (result.code === 200) {
          this.list = result.artists;
          console.log("音乐人", this.list);
        }
      } catch (error) {}
    },
    toSingerDetailsPage(id) {
      this.$router.push(`/singerDetails/${id}`);
    },
    toSingerPage() {
      this.$router.push("/singer");
    },
  },
  computed: {},
};
</script>

<style lang="less" scoped>
.musicPerson {
  margin-top: 40px;
  /deep/ .el-image {
    img {
      border-radius: 50%;
    }
  }
  .content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .content_item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 220px;
      height: 224px;
      border-radius: 8px;
      background-color: #f8f8f8;
      margin-bottom: 15px;
      .content_item_pic {
        position: relative;
        width: 155px;
        height: 155px;
        overflow: hidden;
      }
      .name {
        padding-top: 10px;
        font-size: 14px;

        &:hover {
          color: @globalColor;
          cursor: pointer;
          // animation: bounce 1s;
        }
      }
    }
  }
}
</style>
